package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import com.eastfair.pay.enumeration.ChinaumsLogRequestTypeEnum;
import com.eastfair.pay.enumeration.TransactionOrderOrderTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 调用银联日志
 * </p>
 *
 * @author linan
 * @since 2023-05-30
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("pay_chinaums_log")
@ApiModel(value = "ChinaumsLog", description = "调用银联日志")
@AllArgsConstructor
public class ChinaumsLog extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 业务单号
     */
    @ApiModelProperty(value = "业务单号")
    @Size(max = 255, message = "业务单号长度不能超过255")
    @TableField(value = "order_num", condition = LIKE)
    @Excel(name = "业务单号")
    private String orderNum;

    /**
     * 是否调用成功：1是；0否
     */
    @ApiModelProperty(value = "是否调用成功：1是；0否")
    @TableField(value = "is_success")
    @Excel(name = "是否调用成功：1是；0否")
    private Integer isSuccess;

    /**
     * 请求url
     */
    @ApiModelProperty(value = "请求url")
    @Size(max = 1000, message = "请求url长度不能超过1000")
    @TableField(value = "request_url", condition = LIKE)
    @Excel(name = "请求url")
    private String requestUrl;

    /**
     * 授权
     */
    @ApiModelProperty(value = "授权")
    @Size(max = 255, message = "授权长度不能超过255")
    @TableField(value = "auth", condition = LIKE)
    @Excel(name = "授权")
    private String auth;

    /**
     * 认证报文
     */
    @ApiModelProperty(value = "认证报文")
    @Size(max = 255, message = "认证报文长度不能超过255")
    @TableField(value = "signature", condition = LIKE)
    @Excel(name = "认证报文")
    private String signature;

    /**
     * 请求参数
     */
    @ApiModelProperty(value = "请求参数")
    @Size(max = 65535, message = "请求参数长度不能超过65535")
    @TableField(value = "request_parameter", condition = LIKE)
    @Excel(name = "请求参数")
    private String requestParameter;

    /**
     * 响应结果
     */
    @ApiModelProperty(value = "响应结果")
    @Size(max = 65535, message = "响应结果长度不能超过65535")
    @TableField(value = "response_results", condition = LIKE)
    @Excel(name = "响应结果")
    private String responseResults;

    /**
     * 银联下单单号
     */
    @ApiModelProperty(value = "银联下单单号")
    @Size(max = 255, message = "银联下单单号长度不能超过255")
    @TableField(value = "mer_order_id", condition = LIKE)
    @Excel(name = "银联下单单号")
    private String merOrderId;

    /**
     * 银联退款单号
     */
    @ApiModelProperty(value = "银联退款单号")
    @Size(max = 255, message = "银联退款单号长度不能超过255")
    @TableField(value = "refund_order_id", condition = LIKE)
    @Excel(name = "银联退款单号")
    private String refundOrderId;

    /**
     * 付款金额
     */
    @ApiModelProperty(value = "付款金额")
    @TableField(value = "total_amount")
    @Excel(name = "付款金额")
    private Long totalAmount;

    /**
     * 退款金额
     */
    @ApiModelProperty(value = "退款金额")
    @TableField(value = "refund_amount")
    @Excel(name = "退款金额")
    private Long refundAmount;

    /**
     * 请求类型 #{PAY:下单支付;QUERY:查询;REFUND:退款}
     */
    @ApiModelProperty(value = "请求类型 #{PAY:下单支付;QUERY:查询;REFUND:退款}")
    @TableField(value = "request_type")
    @Excel(name = "请求类型 #{PAY:下单支付;QUERY:查询;REFUND:退款}", replace = {"下单支付_PAY", "查询_QUERY", "退款_REFUND",  "_null"})
    private ChinaumsLogRequestTypeEnum requestType;

    /**
     * 业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮}
     */
    @ApiModelProperty(value = "业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮}")
    @TableField(value = "order_type")
    @Excel(name = "业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮}", replace = {"合同_CONTRACT", "服务_SERVICE", "证件_CERTIFICATE", "加班_WORKEXTRA", "罚款_FINE", "保证金_BOND", "展览_EXHIBITION", "会议_MEETING", "餐饮_FOOD",  "_null"})
    private TransactionOrderOrderTypeEnum orderType;

    /**
     * 银联支付方式
     */
    @ApiModelProperty(value = "银联支付方式")
    @Size(max = 255, message = "银联支付方式长度不能超过255")
    @TableField(value = "inst_mid", condition = LIKE)
    @Excel(name = "银联支付方式")
    private String instMid;

    /**
     * 微信用户子标识
     */
    @ApiModelProperty(value = "微信用户子标识")
    @Size(max = 255, message = "微信用户子标识长度不能超过255")
    @TableField(value = "sub_open_id", condition = LIKE)
    @Excel(name = "微信用户子标识")
    private String subOpenId;


    @Builder
    public ChinaumsLog(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String orderNum, Integer isSuccess, String requestUrl, String auth, String signature, String requestParameter, 
                    String responseResults, String merOrderId, String refundOrderId, Long totalAmount, Long refundAmount, ChinaumsLogRequestTypeEnum requestType,
                       TransactionOrderOrderTypeEnum orderType, String instMid, String subOpenId) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.orderNum = orderNum;
        this.isSuccess = isSuccess;
        this.requestUrl = requestUrl;
        this.auth = auth;
        this.signature = signature;
        this.requestParameter = requestParameter;
        this.responseResults = responseResults;
        this.merOrderId = merOrderId;
        this.refundOrderId = refundOrderId;
        this.totalAmount = totalAmount;
        this.refundAmount = refundAmount;
        this.requestType = requestType;
        this.orderType = orderType;
        this.instMid = instMid;
        this.subOpenId = subOpenId;
    }

}
